<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>10京东搜索框案例</title>
    <style>
        .box {
            width: 300px;
            margin: 100px auto;
            /* border: 1px solid red; */
        }
    </style>
</head>

<body>
    <div class="box">
        <input type="text">
        <label for="">搜索</label>
    </div>
    <script>
        var ipt=document.querySelector("input");
        document.addEventListener('keyup',function(e){
            console.log(e.keyCode);
            if(e.keyCode===83){
                ipt.focus();
                //搜索框获得焦点
            }
        })
    </script>

</body>

</html>